﻿using System;
using System.Web.UI;

namespace MikeKappel.Com.CS
{
    public static partial class Javascript
    {
        public static void RegisterScriptSrc(Page CurrentPage, String Src)
        {
            ScriptManager sm = ScriptManager.GetCurrent(CurrentPage);
            if (sm == null)
            {
                System.Web.UI.HtmlControls.HtmlGenericControl ScriptHead = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
                ScriptHead.Attributes.Add("type", "text/javascript");
                ScriptHead.Attributes.Add("src", CurrentPage.ResolveUrl(Src));
                CurrentPage.Header.Controls.Add(((Control)ScriptHead));
            }
            else
            {
                sm.Scripts.Add(new ScriptReference(CurrentPage.ResolveUrl(Src)));
            }
        }
    }
}